<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>调用Lua函数</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="lua.assign.html">« Lua::assign</a></li>
      <li style="float: right;"><a href="lua.construct.html">Lua::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.lua.html">Lua</a></li>
    <li>调用Lua函数</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="lua.call" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Lua::call</h1>
  <h1 class="refname">Lua::__call</h1>
  <p class="verinfo">(PECL lua &gt;=0.9.0)</p><p class="refpurpose"><span class="refname">Lua::call</span> -- <span class="refname">Lua::__call</span> &mdash; <span class="dc-title">调用Lua函数</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-lua.call-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Lua::call</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$lua_func</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$args</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$use_self</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><strong>Lua::__call</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$lua_func</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter">$args</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$use_self</code><span class="initializer"> = 0</span></span>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">

  </p>

  <div class="warning"><strong class="warning">警告</strong><p class="simpara">本函数还未编写文档，仅有参数列表。</p></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-lua.call-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">lua_func</code></dt>

    <dd>

     <p class="para">
       lua中的函数名。
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">args</code></dt>

    <dd>

     <p class="para">
      向Lua函数传入的参数。
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">use_self</code></dt>

    <dd>

     <p class="para">
       是否使用<code class="literal">self</code>。
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-lua.call-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回调用函数的结果，参数错误返回<strong><code>null</code></strong> ，其它错误返回<strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-lua.call-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-3430">
   <p><strong>示例 #1 <span class="function"><strong>Lua::call()</strong></span>示例</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$lua&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Lua</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$lua</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">eval</span><span style="color: #007700">(&lt;&lt;&lt;CODE<br /></span><span style="color: #DD0000">&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;dummy(foo,&nbsp;bar)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print(foo,&nbsp;",",&nbsp;bar)<br />&nbsp;&nbsp;&nbsp;&nbsp;end<br /></span><span style="color: #007700">CODE<br />);<br /></span><span style="color: #0000BB">$lua</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">call</span><span style="color: #007700">(</span><span style="color: #DD0000">"dummy"</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">"Lua"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"geiliable\n"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$lua</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">dummy</span><span style="color: #007700">(</span><span style="color: #DD0000">"Lua"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"geiliable"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;__call()<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$lua</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">call</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"table"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"concat"</span><span style="color: #007700">),&nbsp;array(array(</span><span style="color: #0000BB">1</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">3</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"-"</span><span style="color: #007700">)));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Lua,geiliable
Lua,geiliable
string(5) &quot;1-2-3&quot;
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-lua.call-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><a href="language.oop5.overloading.html#object.call" class="link">__call()</a></li>
  </ul>
 </div>


</div></div></div></body></html>